package leetcode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-15
 * Time: 20:23
 */
class Solution {
    public int firstUniqChar(String s) {
        char[] arr1 = s.toCharArray();
        long[] arr2 = new long[26];
        for (int i = 0; i < arr1.length; i++) {
            int ch = arr1[i] - 97;
            arr2[ch]++;
        }
        for (int i = 0; i < arr1.length; i++) {
            if(arr2[arr1[i] - 97] == 1) {
                return i;
            }
        }
        return -1;
    }
}
public class Test {
    public static void main(String[] args) {
        Solution solution = new Solution();
        String s = "aaaaaa";
        System.out.println(solution.firstUniqChar(s));
    }
}
